package com.ruoyi.buss.report.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.buss.utils.ListUtil;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.report.domain.ReportWgsqLsb;
import com.ruoyi.buss.report.service.IReportWgsqLsbService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 网格社区报表Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/reportLsb")
public class ReportWgsqLsbController extends BaseController
{
    @Autowired
    private IReportWgsqLsbService reportWgsqLsbService;

    @Autowired
    private TokenService tokenService;

    /**
     * 4.2.2-2  网格社区业务进度表包片居民
     */
    @PreAuthorize(hasPermi = "buss:wgsqlsb:list")
    @GetMapping("/wgsqywjdb")
    public TableDataInfo list(ReportWgsqLsb reportWgsqLsb)
    {
        reportWgsqLsb.setSjrq(ListUtil.getSjrq(reportWgsqLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportWgsqLsb> list = reportWgsqLsbService.selectReportWgsqLsbList(reportWgsqLsb,userInfo,0);
        return getDataTable(list);
    }

    /**
     * 4.2.2-2  网格社区业务进度表包片居民
     */
    @PreAuthorize(hasPermi = "buss:wgsqywjdbhz:list")
    @GetMapping("/wgsqywjdbhz")
    public TableDataInfo wgsqywjdbhz(ReportWgsqLsb reportWgsqLsb)
    {
        reportWgsqLsb.setSjrq(ListUtil.getSjrq(reportWgsqLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportWgsqLsb> list = reportWgsqLsbService.selectReportWgsqLsbList(reportWgsqLsb,userInfo,1);
        return getDataTable(list);
    }

    /**
     * 4.2.2-2  网格社区业务进度表包片居民
     */
    @PreAuthorize(hasPermi = "buss:wgsqywjdbMonth:list")
    @GetMapping("/wgsqywjdbMonth")
    public TableDataInfo wgsqywjdbMonth(ReportWgsqLsb reportWgsqLsb)
    {
        reportWgsqLsb.setSjrq(ListUtil.getSjrq(reportWgsqLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportWgsqLsb> list = reportWgsqLsbService.selectReportWgsqLsbList(reportWgsqLsb,userInfo,2);
        return getDataTable(list);
    }

    /**
     * 导出网格社区报表列表
     */
    @PreAuthorize(hasPermi = "buss:wgsqlsb:export")
    @Log(title = "网格社区报表", businessType = BusinessType.EXPORT)
    @PostMapping("/exportWgsqywjdbService")
    public void export(HttpServletResponse response, ReportWgsqLsb reportWgsqLsb) throws IOException
    {
        reportWgsqLsb.setSjrq(ListUtil.getSjrq(reportWgsqLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        List<ReportWgsqLsb> list = reportWgsqLsbService.selectReportWgsqLsbList(reportWgsqLsb,userInfo,0);
        ExcelUtil<ReportWgsqLsb> util = new ExcelUtil<ReportWgsqLsb>(ReportWgsqLsb.class);
        util.exportExcel(response, list, "网格社区报表数据");
    }


}
